//
//  ACSettingsModel.m
//  acfun_video
//
//  Created by user on 11/24/15.
//  Copyright © 2015 wang. All rights reserved.
//

#import "ACSettingsMethod.h"

extern ACArticleFontType ACArticleFontTypeInSetting() {
    id fontTypeObject = kGetSetting(kArticleFontType);//获取userDefault存储的字体大小 @(ACArticleFontType)枚举值
    if (!fontTypeObject) {//如果不存在
        ACArticleFontTypeResetToDefault();//调用恢复默认设置函数 设置为正常大小 ACArticleNormalFont 并且存入userDefault
        fontTypeObject = kGetSetting(kArticleFontType);//然后再userDefault读取出来
    }
    return (ACArticleFontType)[fontTypeObject integerValue];//NSNumber转换为int值
}

extern void ACArticleFontTypeUpdateInSetting(ACArticleFontType type) {
    kSaveSetting(kArticleFontType, @(type));
}

extern void ACArticleFontTypeResetToDefault() {
    ACArticleFontTypeUpdateInSetting(ACArticleNormalFont);
}

extern NSString *ACArticleDefaultFontTypeTitle() {
    return ACArticleFontTitle(ACArticleFontTypeInSetting());
}

///图片智能加载,返回yes,在3g环境下不加载图片,相当于无图模式
extern BOOL ACArticleLoadImageWisely() {
    id articleLoadImageMode = kGetSetting(kIsLoadingImg);
    if (!articleLoadImageMode) {
        ACArticleUpdateImageMode(NO);
        articleLoadImageMode = kGetSetting(kIsLoadingImg);
    }
    return [articleLoadImageMode boolValue];
}

extern void ACArticleUpdateImageMode(BOOL isLoadImageWisely) {
    kSaveSetting(kIsLoadingImg, @(isLoadImageWisely));
}

